package com.mycompany.testcases.chee;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import com.mycompany.project.client.ModuleType;
import com.mycompany.project.client.chee.HabitatConfiguration;
import com.mycompany.project.client.chee.Module;
import com.mycompany.project.client.chee.ModuleList;

public class HabitatConfigurationTest{

private static HabitatConfiguration configurationTest = new HabitatConfiguration();
	
	@Before
	public void initMList()
	{
		//initialze the module list first
		ModuleList.getMlist().clear();
		ModuleList.initMList();
		
	}
	
	@Test
	public void test1() {
		//this test will check to make sure the size is correct.
		configurationTest.initList();
		
		assert configurationTest.getGridList()  != null;
		assert configurationTest.getMlist()  != null;
		assert configurationTest.getModuleNumber()  != null;
		
		assertEquals(configurationTest.getGridList().size(),10);
		assertEquals(configurationTest.getMlist().size(),10);
		assertEquals(configurationTest.getModuleNumber().size(),10);
	}
	@Test
	public void test2() {
		//this test will check to make sure we aren't able to
		//build a min or max configuration, yet because initially
		//the module list is empty and therefore does not meet
		//the requirement to build either min or max configurations.
		
		assertEquals(configurationTest.buildMax(null),false);
		assertEquals(configurationTest.buildMin(null),false);
	}
	
	@Test
	public void test3(){
		
		//add the minimum modules to the module list and
		//verify that we can build a min configuration
		//for simplicity and test purposes we'll make 
		//modules with empty data
		for(int i=0;i<3;i++)//place 3 plains
		{
			Module m = new Module();
			m.setModuleType(ModuleType.PLAIN);
			m.setCodeNumber(1);
			m.setPositionX(1);
			m.setPositionY(1);
			m.setOrientation(1);
			m.setStats("usable");//make sure it's usable
			ModuleList.getMlist().get(0).add(m);
		}
		//place 1 of each module onto list
		for(int i=1;i<10;i++)//place 3 plains
		{
			Module m = new Module();
			m.setModuleType(Module.checkModuleType(i));
			m.setCodeNumber(1);
			m.setPositionX(1);
			m.setPositionY(1);
			m.setOrientation(1);
			m.setStats("usable");//make sure it's usable
			ModuleList.getMlist().get(i).add(m);
		}
		assertEquals(configurationTest.buildMax(null),true);
		assertEquals(configurationTest.buildMin(null),true);
	}
	

}
